
<style lang="less">
	page{
		background-color: #F3F3F3;
		padding: 20upx 0 30upx;
	}
	.project{
		padding: 0 30upx;
		box-sizing: border-box;
		background: #FFFFFF;
	}
	.project_list{
		padding: 22upx 0 40upx;
		border-bottom: 1upx solid #EAEAEA;
		&:last-of-type{
			border-bottom: none;
		}
		.project_item{
			margin-top: 22upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		.project_item_fl{
			flex: 1;
			overflow:hidden;
			text-overflow:ellipsis;
			display:-webkit-box;
			-webkit-box-orient:vertical;
			-webkit-line-clamp:1;
			word-break: break-all;
			font-size: 26upx;
			font-weight: 500;
			color: #333333;
			line-height: 30upx;
		}
		.project_item_fr{
			font-size: 24upx;
			font-weight: 500;
			color: #999999;
			line-height: 29upx;
		}
		.price{
			font-size: 40upx;
			font-family: "DINCond";
			font-weight: 400;
			color: #333333;
			line-height: 48upx;
		}
	}
</style>


<template>

	<view class="container">
		<view class="project">
			<view class="project_list" v-for="(v,i) in list" :key="i">
				<view class="project_item">
					<view class="project_item_fl">{{v.remark}}</view>
					<view class="project_item_fr">{{v.creatTime}}</view>
				</view>
				<view class="project_item">
					<view class="project_item_fr">账户总金额 {{v.balanceCurrent}}</view>
					<view class="price">{{v.priceCurrent}}</view>
				</view>
			</view>
		</view>
		<view class="uni-loadmore" v-if="showLoadMore">{{loadMoreText}}</view>
	</view>

</template>

<script>
	import api from '@/common/api';
  export default {

    components: {},

    data () {

      return {
		  list:[],
		  token: '',
		  page:1,
		  loadMoreText: "加载中...",
		  showLoadMore: false,
		  totalPage:'',//总页数
	  }
    },
	onLoad() {
		this.token = uni.getStorageSync('token')
		this.newList()
	},
    methods: {
		//列表
		async newList(page){
			const [err, res] = await api.newList({
				query: {
					page: this.page,
					type: 0,
					earningsType: 18,
					orderType: 6,
					limit: 10
				},
				 header:{
					'Content-Type': 'application/json',
					'token': this.token
				 }
			 });
			 if(res.data.code == 0){
				 this.list = [...this.list, ...res.data.data.list];
				  this.totalPage=res.data.data.totalPage
				  if(this.list.length==0){
				 	  this.loadMoreText = "暂无数据!"
				 	 this.showLoadMore = true;
				 }else{
				 	this.showLoadMore = false; 
				 }
			 }
		},
	},
	onReachBottom() {
		this.showLoadMore = true;
		if (this.page >= this.totalPage) {
			this.loadMoreText = "没有更多数据了!"
			return;
		}else{
			setTimeout(() => {
				this.page++
				this.newList()
			}, 500);
		}
	},
	//下拉刷新
	 onPullDownRefresh() {
		//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
		this.page=1
		this.list=[]
		this.newList()
		setTimeout(function () {
			uni.stopPullDownRefresh();  //停止下拉刷新动画
		}, 1000);
	}

  }
</script>